package com.yfp.operation.service.impl;

import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingReceiverRequest;
import com.github.binarywang.wxpay.bean.profitsharing.request.ProfitSharingRequest;
import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingReceiverResult;
import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingResult;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.yfp.operation.service.YFPWxPayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description: 微信支付
 *
 * @CreateDate: 2024/6/7 15:46
 * @UpdateUser:
 * @UpdateDate: 2024/6/7 15:46
 * @UpdateRemark: 暂无修改
 * @Version: 1.0
 */
@Slf4j
@Service
public class YFPWxPayServiceImpl implements YFPWxPayService {

    @Autowired
    private WxPayService wxPayService;


    /**
     * 分账
     * @param profitSharingRequest
     * @return
     */
    @Override
    public String profitsharing(ProfitSharingRequest profitSharingRequest) throws Exception {
        ProfitSharingResult profitSharingResult = wxPayService.getProfitSharingService().profitSharing(profitSharingRequest);
        log.info("分账返回结果：{}", profitSharingResult);
        return profitSharingResult.getResultCode();
    }

    /**
     * 添加分账接受方
     * @param profitSharingReceiverRequest
     * @return
     * @throws WxPayException
     */
    @Override
    public String addReceiver(ProfitSharingReceiverRequest profitSharingReceiverRequest) throws WxPayException {
        ProfitSharingReceiverResult profitSharingReceiverResult = wxPayService.getProfitSharingService().addReceiver(profitSharingReceiverRequest);
        log.info("创建分账接收方返回结果：{}", profitSharingReceiverResult);
        return profitSharingReceiverResult.getResultCode();
    }

    /**
     * 删除分账接收方
     * @param profitSharingReceiverRequest
     * @return
     */
    @Override
    public String removeReceiver(ProfitSharingReceiverRequest profitSharingReceiverRequest) throws WxPayException {
        ProfitSharingReceiverResult profitSharingReceiverResult = wxPayService.getProfitSharingService().removeReceiver(profitSharingReceiverRequest);
        log.info("删除分账接收方返回结果：{}", profitSharingReceiverResult);
        return profitSharingReceiverResult.getResultCode();
    }
}
